import { createRouter, createWebHistory } from "vue-router";
import Home from "../views/Home.vue";

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/about",
    name: "About",
    component: () => import("../views/About.vue"),
  },
  // .....
  {
    path: "/m",
    name: "m",
    component: () => import("../views/Mobile"),
    children: [
      {
        path: "",
        name: "m-home",
        component: () => import("@/views/M/MHome"),
      },
      {
        path: "mine",
        name: "m-mine",
        component: () => import("@/views/M/MMine"),
      },
    ]
  },
  {
    path: "/admin",
    name: "Admin",
    component: () => import("@/views/Admin"),
    // /admin/news
    // /admin/news/create
    // /admin/news/:id
    // /admin/news/:id/edit
    children: [
      // /admin
      {
        path: "",
        name: "AdminDashboard",
        component: () => import("@/views/Admin/AdminDashboard"),
      },
      {
        path: "news",
        name: "AdminNews",
        component: () => import("@/views/Admin/AdminNews"),
      },
      {
        path: "news/create",
        name: "AdminNewsCreate",
        component: () => import("@/views/Admin/AdminNewsCreate"),
      },
      {
        path: "news/:id",
        name: "AdminNewsShow",
        component: () => import("@/views/Admin/AdminNewsShow"),
      },
      {
        path: "news/:id/edit",
        name: "AdminNewsEdit",
        component: () => import("@/views/Admin/AdminNewsEdit"),
      },
      // ....
    ],
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
